import request from "@/api";
import { ListRet } from "@/api/response";

class EnumApi {
  /**
   * 查询枚举类型数据
   * @param enumName
   * @returns
   */
  private static async QueryEnumList(enumName: string): Promise<EnumData[]> {
    return await request({
      url: `Common/GetEnumList/${enumName}`,
      method: "get",
    });
  }

  /**
   * 查询菜单枚举数据
   * @returns
   */
  static async QueryMenuTypeEnums(): Promise<EnumData[]> {
    return await this.QueryEnumList(EnumTypeName.ApiMenuTypeEnum);
  }

  /**
   * 查询公式变量类型枚举数据
   * @returns
   */
  static async QueryFormulaVariableTypeEnums(): Promise<EnumData[]> {
    return await this.QueryEnumList(EnumTypeName.ApiFormulaVariableTypeEnum);
  }
}

export default EnumApi;

export interface EnumData {
  name: string;
  value: number;
  text: string;
  disabled: boolean;
}

export enum EnumTypeName {
  ApiMenuTypeEnum = "MenuTypeEnum",
  ApiFormulaVariableTypeEnum = "FormulaVariableTypeEnum",
}
